package com.lwp.spring.filter;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * TestFilter 自定义过滤器
 * <p>
 *     DelegatingFilterProxy 纳入 spring管理的filter
 * </p>
 *
 * @author lanwenping
 * @version 1.0
 * @date 2020/6/7 14:31
 */
//@WebFilter(urlPatterns = {"/*"})
public class TestFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println(getClass().getName() + " init");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        chain.doFilter(request, response);

        System.out.println(getClass().getName() + " doFilter");
    }

    @Override
    public void destroy() {
        System.out.println(getClass().getName() + " destroy");
    }
}
